package com.woniuxy.credit_loans.audit_li.controller;

import com.woniuxy.credit_loans.accounting_shi.service.DebitInfoService;
import com.woniuxy.credit_loans.audit_li.dto.AuditInfoDto;
import com.woniuxy.credit_loans.audit_li.dto.MyApproval;
import com.woniuxy.credit_loans.audit_li.service.AuditInfoService;
import com.woniuxy.credit_loans.collection_zhang.service.BonaService;
import com.woniuxy.credit_loans.entity.DebitInfo;
import com.woniuxy.credit_loans.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/auditInfoLi")
public class AuditInfoController {
    @Autowired
    private AuditInfoService auditInfoService;
    @Autowired
    private BonaService bonaService;
    @Autowired
    private DebitInfoService debitInfoService;

    @PostMapping("/auditchufu")
    public Result addAudichufu(@RequestBody AuditInfoDto auditInfoDto){

        int i = auditInfoService.insertSelectiveByDiNumber(auditInfoDto);
        DebitInfo debitInfo = debitInfoService.selectByPrimaryKey(Long.valueOf(auditInfoDto.getDiNumber()));
        debitInfo.setDiDebitStatus("待终审");
        debitInfoService.updateByPrimaryKeySelective(debitInfo);


        return Result.ok();

    }
    @PostMapping("/auditzhong")
    public Result addAudizhong(@RequestBody AuditInfoDto auditInfoDto){

        int i = auditInfoService.insertSelectiveByDiNumber(auditInfoDto);
        DebitInfo debitInfo = debitInfoService.selectByPrimaryKey(Long.valueOf(auditInfoDto.getDiNumber()));
        debitInfo.setDiDebitStatus("终审通过");
        debitInfoService.updateByPrimaryKeySelective(debitInfo);
        return Result.ok();

    }
    @PostMapping("/auditchuWei")
    public Result addAudiWei(@RequestBody AuditInfoDto auditInfoDto){

        int i = auditInfoService.insertSelectiveByDiNumber(auditInfoDto);
        DebitInfo debitInfo = debitInfoService.selectByPrimaryKey(Long.valueOf(auditInfoDto.getDiNumber()));
        debitInfo.setDiDebitStatus("初审驳回");
        debitInfoService.updateByPrimaryKeySelective(debitInfo);


        return Result.ok();

    }
    @PostMapping("/auditzhongWei")
    public Result addAudiWeit(@RequestBody AuditInfoDto auditInfoDto){

        int i = auditInfoService.insertSelectiveByDiNumber(auditInfoDto);
        DebitInfo debitInfo = debitInfoService.selectByPrimaryKey(Long.valueOf(auditInfoDto.getDiNumber()));
        debitInfo.setDiDebitStatus("终审驳回");
        debitInfoService.updateByPrimaryKeySelective(debitInfo);


        return Result.ok();

    }

}
